package com.white.bean;

import com.baomidou.mybatisplus.annotation.TableId;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * -- 文章ID、作者ID、文章名称、总字数、文章内容、浏览数、点赞数、评论数、赞赏数、发布时间。
 * create table article(
 * articleId int primary key AUTO_INCREMENT comment "文章ID",
 * userId int comment "创作文章的用户ID",
 * foreign key(userId) REFERENCES user(userId) on delete cascade on update cascade,
 * classifyId int comment "文章分类ID",
 * foreign key(classifyId) REFERENCES classify(classifyId) on delete cascade on update cascade,
 * title varchar(256) unique comment "书名",
 * content longtext comment "内容",
 * description varchar(256) comment "文章描述",
 * cover varchar(255) comment "封面",
 * words int not null default 0 comment "总字数",
 * views int not null default 0 comment "浏览总数",
 * comments int not null default 0 comment "评论总数",
 * rewards int not null default 0 comment "赞赏总数",
 * createTime TIMESTAMP not null default CURRENT_TIMESTAMP comment "发布时间，默认当前时间戳"
 * );
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Article implements Serializable {
    /*只能标注到一个属性列*/
    @TableId(value = "articleId")
    private Long articleId;
    private Long userId, classifyId;
    private int words, likes, views, comments, rewards;
    private double viewDuration;
    private String title, description, content, cover, createTime;

    public Article(Long userId, Long classifyId, String title, String description, String content, int words) {
        this.userId = userId;
        this.classifyId = classifyId;
        this.title = title;
        this.description = description;
        this.content = content;
        this.words = words;
    }
}
